var app = getApp();
const apiHost = require('../../common/api_host.js');
var utils = require('../../utils/utils.js');
var httpJson=require('../../utils/http_json.js');
Component({
  properties: {
    // 这里定义了innerText属性，属性值可以在组件使用时指定
    avatar: {
      type: String,
      value: '',
    },
    uname: {
      type: String,
      value: '',
    },
    cardContent:{
      type: String,
      value: '',
    },
    look:{
      type: Number,
      value: '',
    },
    comment:{
      type: Number,
      value: '',
    },
    amaze:{
      type: Number,
      value: '',
    },
    isRoom:{
      type:Boolean,
      // value:""
    },
    
    myid:{
      // 这里应该是id
      type:Number
    },
    isReply:{
      // 这里应该是id
      type:Boolean,
      value:false
    },
    reply:{
      type:String,
      
    },
    mytime:String,
    userlike:Boolean,
    contentid:Number,
    nd:Number,
    imgurl:String,
    bereplyname:String
    // addContentLike:Boolean

  },
  data: {
    // 这里是一些组件内部数据
    someData: {
      
    }
  },
  methods: {
    formSubmit: function(e) {


      var formId = e.detail.formId;
    
      let path = `${apiHost.config.portalApiHost}/portal/userformId/add`;
      httpJson.post(path, { 'formId': formId}, function (data) {
        let res = data.data;
       
      })
     
    },
    addContentLike:function(){
     
      this.triggerEvent('addlike', {}) // 只会触发 pageEventListener2
    },
    toDetail:function(e){
       //点击区域时转发的话就不跳转到详情页面
   console.log(e,e.target.dataset)
    if(e.target.dataset.reply==1){
      return;
    }
    //如果是表单提交就返回
    if(e.target.dataset.mysubmit==1){
      return;
    }
      // this.triggerEvent('todetail', {}) // 只会触发 pageEventListener2
      let  contentid=e.currentTarget.dataset.contentid;
      if(e.currentTarget.dataset.nd){
        // debugger
         
         wx.navigateTo({
          url:"/pages/index/room/detail/detail?id="+contentid+'&nd=1'
        })
      }
     
      else{
        // debugger
          wx.navigateTo({
            url:"/pages/index/room/detail/detail?id="+contentid
          })
      }
     
    },
    toReply:function(){
      this.triggerEvent('toReply', {})
    },
      
  onShareAppMessage(res) {
    let content=res.target.dataset.content
    console.log('res!@~~',res)
    if(content.length>50){
      content=content.substr(0,50)+'...'
    }
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: content,
     
    }
  }
   
  },
  
})